<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>初识Vue</title>
		<!-- 1.使用这些API:push()、pop()、shift()、unshift()、splice()、sort()、reverse() -->
		<script type="text/javascript" src="../js/vue.js"></script>
	</head>
	<body>
		
		<div id="root">
			<h2>学校名称：{{name}}</h2>
			<h2>学校地址：{{address}}</h2>
			<h2>学生性别：{{student.sex}}</h2>
			<h2>学生地址：{{student.name}}</h2>
			<h2>学生年龄：{{student.age}}</h2>
			<button @click="addsex">点击加性别</button>
			<ul>
				<li v-for="f in friends" :key="f.id">
                    {{f.name}}-{{f.age}}
				</li>
			</ul>
			<ul>
				<li v-for="(h,index) in hobby" :key="index">
                    {{h}}-{{h}}
				</li>
			</ul>
			<button @click="update">修改数组</button>
		</div>

		<script type="text/javascript" >
			Vue.config.productionTip = false //阻止 vue 在启动时生成生产提示。
			const vm= new Vue({
				el:"#root",
				data:{
                   name:"123",
				   address:"456",
				   student:{
					   name:"147",
					   age:18,
					  // sex:"男"
				   },
				   hobby:["1","2","3"],
				   friends:[
					   {id:"001",
					    name:"123",
					    age:18},
						{id:"002",
					    name:"123",
					    age:28},
				   ]   
				},
				methods: {
					addsex(){
						//Vue.set(vm.student,'sex','男')
						this.$set(this.student, 'sex','女')
					},
					update(){
						this.hobby.push("5")
					}
				},
			})
            let data ={
				name:"123",
				address:"456"
			}
			
	
		</script>
	</body>
</html>

